﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using MvcContrib.UI.InputBuilder.Helpers;

namespace Peak.Web.Controllers.Models
{
  public static class ModelStateDictionaryExtension
  {
    public static void AddModelError<T>(this ModelStateDictionary modelState, Expression<Func<T, object>> action, string error)
    {
      string name = ReflectionHelper.FindProperty(action).Name;

      modelState.AddModelError(name, error);
    }
  }
}
